﻿var app = angular.module("app", []);
app.controller("home_controller", ["$scope", "$timeout", "$interval", function($scope, $timeout, $interval) {
//	$scope.animate = false;
//	$scope.all_game = false;
//	$scope.scroll = function() {
//		$scope.animate = true;
//		$timeout(function() {
//			$scope.luck_list.shift();
//			$scope.animate = false
//		}, 500)
//	};
//	$scope.luck_timer = $interval(function() {
//		$scope.scroll()
//	}, 2000);
	$scope.pop_b_select = function() {
		mui("#b_select_container").popover("toggle", document.getElementById("b_select_btn"))
	};
	$scope.show_all_game = function(e) {
		$scope.all_game = !$scope.all_game;
		if($scope.all_game) {
			$(e.currentTarget).html('收起<i class="mui-icon mui-icon-arrowup"></i>')
		} else {
			$(e.currentTarget).html('全部游戏<i class="mui-icon mui-icon-arrowdown"></i>')
		}
	};
	$scope.goPage = function(path) {
		mui.openWindow({
			url: path
		})
	};
	var gallery = mui(".mui-slider");
	gallery.slider({
		interval: 3000
	});
	$scope.close_update = function() {
		mui("#pop_update").popover("hide")
	}
}]);

//文字滚动
window.onload = function() {
	//获取元素的函数;
	function $(id) {
		return document.getElementById(id);
	}

	function startmarquee(lh, speed, delay) {
		var p = false;
		var t;
		var o = $('luck_list');
		o.innerHTML += o.innerHTML;
		o.style.marginTop = 0;
		o.onmouseover = function() {
			p = true;
		}
		o.onmouseout = function() {
			p = false;
		}

		function start() {
			t = setInterval(scrolling, speed);
			if(!p) {
				o.style.marginTop = parseInt(o.style.marginTop) - 1 + 'px';
			}
		}

		function scrolling() {
			if(parseInt(o.style.marginTop) % lh != 0) {
				o.style.marginTop = parseInt(o.style.marginTop) - 1 + 'px';
				if(Math.abs(parseInt(o.style.marginTop)) >= o.scrollHeight / 2) {
					o.style.marginTop = 0;
				}
			} else {
				clearInterval(t);
				setTimeout(start, delay);
			}
		}
		setTimeout(start, delay);
	}
	startmarquee(40, 15, 1500);
}